import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

import '../../generated/assets.dart';
import '../../generated/l10n.dart';

class QaWebWidget extends StatefulWidget {
  final con =
      WebViewController()..setJavaScriptMode(JavaScriptMode.unrestricted);

  QaWebWidget({super.key});

  @override
  State<QaWebWidget> createState() => _QAWidgetState();
}

class _QAWidgetState extends State<QaWebWidget> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    widget.con
      ..setNavigationDelegate(
        NavigationDelegate(
          onProgress:
              (progress) =>
                  print('=============== Loading progress: $progress%'),
          onPageStarted: (url) => print('=============== Page started: $url'),
          onPageFinished: (url) async {},
          onNavigationRequest: (request) {
            print('=============== Navigating to: ${request.url}');
            return NavigationDecision.navigate;
          },
        ),
      )
      // ..loadHtmlString("${Assets.htmlIndex}#/policy");
      ..loadFlutterAsset(Assets.htmlIndex);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('飞机2')),
      body: WebViewWidget(controller: widget.con),
    );
  }
}
